package com.example.primomobile.utils;

import java.util.HashMap;

import android.widget.ImageView;

import com.example.primomobile.R;

public class Utils {
	public static final String REMOVE = "REMOVE";
	public static final String PECA = "PECA";
	public static final String DEFAULT = "DEFAULT";
	public static final String FRENTE = "FRENTE";
	public static final String ESQUERDA = "ESQUERDA";
	public static final String DIREITA = "DIREITA";
	public static final String FUNCAO = "FUNCAO";
	public static final String POSICAO = "POSITION";
	public static final String PECA_TROCA = "PECA_FUNCAO";
	public static final String IMG_ANTERIOR = "IMG_ANTERIOR";

	@SuppressWarnings( "unchecked" )
	public static ImageView getImageParaTabuleiro( int count, ImageView view ) {
		HashMap<String, Object> hashMap = (HashMap<String, Object>) view.getTag();
		if ( ( ( count ) / 4 ) % 2 == 0 ) {
			if ( ( count + 1 ) % 4 == 0 ) {

				if ( ( (String) hashMap.get( PECA ) ).equals( FRENTE ) ) {
					view.setImageResource( R.drawable.frente2 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( ESQUERDA ) ) {
					view.setImageResource( R.drawable.esquerda2 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DIREITA ) ) {
					view.setImageResource( R.drawable.direita2 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( FUNCAO ) ) {
					view.setImageResource( R.drawable.funcao2 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DEFAULT ) ) {
					view.setImageResource( R.drawable.img_default2 );
				}

			} else if ( ( count ) % 4 == 0 ) {
				if ( ( (String) hashMap.get( PECA ) ).equals( FRENTE ) ) {
					view.setImageResource( R.drawable.frente6 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( ESQUERDA ) ) {
					view.setImageResource( R.drawable.esquerda6 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DIREITA ) ) {
					view.setImageResource( R.drawable.direita6 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( FUNCAO ) ) {
					view.setImageResource( R.drawable.funcao5 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DEFAULT ) ) {
					view.setImageResource( R.drawable.img_default6 );
				}

			} else {
				if ( ( (String) hashMap.get( PECA ) ).equals( FRENTE ) ) {
					view.setImageResource( R.drawable.frente1 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( ESQUERDA ) ) {
					view.setImageResource( R.drawable.esquerda1 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DIREITA ) ) {
					view.setImageResource( R.drawable.direita1 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( FUNCAO ) ) {
					view.setImageResource( R.drawable.funcao1 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DEFAULT ) ) {
					view.setImageResource( R.drawable.img_default1 );
				}

			}

		} else {

			if ( ( count + 1 ) % 4 == 0 ) {

				if ( ( (String) hashMap.get( PECA ) ).equals( FRENTE ) ) {
					view.setImageResource( R.drawable.frente3 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( ESQUERDA ) ) {
					view.setImageResource( R.drawable.esquerda3 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DIREITA ) ) {
					view.setImageResource( R.drawable.direita3 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( FUNCAO ) ) {
					view.setImageResource( R.drawable.funcao3 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DEFAULT ) ) {
					view.setImageResource( R.drawable.img_default3 );
				}

			} else if ( ( count ) % 4 == 0 ) {
				if ( ( (String) hashMap.get( PECA ) ).equals( FRENTE ) ) {
					view.setImageResource( R.drawable.frente5 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( ESQUERDA ) ) {
					view.setImageResource( R.drawable.esquerda5 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DIREITA ) ) {
					view.setImageResource( R.drawable.direita5 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( FUNCAO ) ) {
					view.setImageResource( R.drawable.funcao4 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DEFAULT ) ) {
					view.setImageResource( R.drawable.img_default5 );
				}

			} else {
				if ( ( (String) hashMap.get( PECA ) ).equals( FRENTE ) ) {
					view.setImageResource( R.drawable.frente4 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( ESQUERDA ) ) {
					view.setImageResource( R.drawable.esquerda4 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DIREITA ) ) {
					view.setImageResource( R.drawable.direita4 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( FUNCAO ) ) {
					view.setImageResource( R.drawable.funcao1 );
				} else if ( ( (String) hashMap.get( PECA ) ).equals( DEFAULT ) ) {
					view.setImageResource( R.drawable.img_default4 );
				}

			}
		}
		return view;
	}
}
